﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Services.Common;
using ADONETDataServicesExtension.BLLUtils;

namespace BLL
{
    [DataServiceKey("Id")]
    [EFEntityType(TypeName = "EFEntities.Role", EntitySetName = "Roles")]
    public class Role : BaseEntityType<EFEntities.Role>
    {
        public Role() : 
            base(() => new EFEntities.Role())
        {
        }
        public Role(EFEntities.Role role)
            : base(role)
        {
        }

        [EFEntityProperty]
        public string Id
        {
            get { return EFEntity.Id; }
            set { EFEntity.Id = value; }
        }

        [EFEntityProperty]
        public string Name
        {
            get { return EFEntity.Name; }
            set { EFEntity.Name = value; }
        }

        private IEnumerable<Employee> _employees;
        [EFEntityProperty]
        public IEnumerable<Employee> Employees
        {
            get
            {
                if (_employees == null)
                    _employees = EFEntity.Employees.AsEnumerable().Select(e => new Employee(e));
                return _employees;
            }
        }
    }
}
